package com.yfbao.horizon.schedule.tk.event;

import io.micrometer.core.instrument.MeterRegistry;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;


@Slf4j
@Component
public class NormalCompent {
    @Autowired
    private ApplicationEventPublisher eventPublisher;
    @Autowired
    private MeterRegistry meterRegistry;

    @EventListener(ApplicationReadyEvent.class)
    public void check() {
        log.info("properties1----------------:"+System.getProperty("management.metrics.tags.enable-jvm","--"));
        log.info("properties2----------------:"+System.getProperty("management.metrics.enable.jvm","--"));
        meterRegistry.getMeters().forEach(meter -> {
            log.info("meter-name:"+meter.getId().getName());
        });

        MyTestEvent event = new MyTestEvent(new Object(), "test");
        eventPublisher.publishEvent(event);
        log.info("publish MyTestEvent");
    }
}
